package com.CMUBiS.util;

/**
 * This class holds the information about the categories that the item can belong to
 * 
 * @author Andy (andrewtu@cmu.edu, turner.andy@gmail.com)
 * @version 0.1
 * @since 0.1
 * @date 04/05/2011
 */
public class Category {
	// Variables to hold the category data
	private int categoryID;
	private String name;
	private int parent;
	private static final boolean immutableWarning = true;

	/**
	 * Create a category with all of the required data
	 * 
	 * @param categoryID
	 * @param name
	 * @param parent
	 * @author Andy (andrewtu@cmu.edu, turner.andy@gmail.com)
	 */
	public Category(int categoryID, String name, int parent){
		this.categoryID = categoryID;
		this.name = name;
		this.parent = parent;
	}
	
	/**
	 * Create a category with just the categoryID
	 * 
	 * @param categoryID
	 * @author Andy (andrewtu@cmu.edu, turner.andy@gmail.com)
	 */
	public void setCategoryID(int categoryID){
		if(Category.immutableWarning) Category.printWarning();
		this.categoryID = categoryID;
	}
	
	/**
	 * Return the categoryID number
	 * 
	 * @return int the category ID number
	 * @author Andy (andrewtu@cmu.edu, turner.andy@gmail.com)
	 */
	public int getCategoryID(){
		return this.categoryID;
	}
	
	/**
	 * Set the name of the category
	 * 
	 * @param name
	 * @author Andy (andrewtu@cmu.edu, turner.andy@gmail.com)
	 */
	public void setName(String name){
		if(Category.immutableWarning) Category.printWarning();
		this.name = name;
	}
	
	/**
	 * Returns the name of the category
	 * 
	 * @return String the name of the category
	 * @author Andy (andrewtu@cmu.edu, turner.andy@gmail.com)
	 */
	public String getName(){
		return this.name;
	}
	
	/**
	 * Sets the parent categoryID of this category
	 * 
	 * @param parent
	 * @author Andy (andrewtu@cmu.edu, turner.andy@gmail.com)
	 */
	public void setParent(int parent){
		if(Category.immutableWarning) Category.printWarning();
		this.parent = parent;
	}
	
	/**
	 * Returns the parent categoryID number of this category
	 * 
	 * @return int the categoryID number for this category's parent
	 * @author Andy (andrewtu@cmu.edu, turner.andy@gmail.com)
	 */
	public int getParent(){
		return this.parent;
	}
	
	/**
	 * Prints immutable object warning
	 * Can be suppressed with immutableWarning=false;
	 * 
	 * @author Andy (andrewtu@cmu.edu, turner.andy@gmail.com)
	 */
	private static void printWarning(){
		System.out.println("Category (printWarning): Please consider using this class as immutable. The 'set' methods may not be doing what you think. They only set values for this Java object and does not set them in the database. Talk to me if you want to change the design - Andy");
	}
}
